 	 * We can call these functions, once our operation is completed.
 	###
 	constructor: (executor) ->
-		self = @
-
-		executor (val) ->
-			self._trigger $resolved, val
-		, (val) ->
-			self._trigger $rejected, val
+		executor genTrigger(@, $resolved), genTrigger(@, $rejected)
 
 	###*
 	 * Appends fulfillment and rejection handlers to the promise,

			reject e
			return $tryErr

	_getX: (hGroup, handler) ->
		try
			handler @_value
		catch e
			hGroup[3] e
			return $tryErr

	###*
	 * Decide how handlers works.
	 * @private
	 * @param  {Yaku} self
	###
	_resolveHanlers: (hGroup) ->
		# Trick: Reuse the value of state as the handler selector.
		# The "i + state" shows the math nature of promise.
		handler = hGroup[@_state]

		if typeof handler == 'function'
			self = @
			nextTick ->
				x = self._getX hGroup, handler
				return if x == $tryErr

				# Prevent circular chain.
				if x == hGroup[4] and x
					return x._trigger $rejected,
						new TypeError $circularErrorInfo

				resolveValue x, hGroup[2], hGroup[3]
		else
			hGroup[2 + @_state] @_value

		return

	_trigger: (state, value) ->
		return if @_state != $pending

		@_state = state
		@_value = value

		i = 0

		while i < @_hCount
			@_resolveHanlers @[i++]

		return


	then: (onFulfilled, onRejected) ->
		self = @

		newYaku = self._hCount + 4

		self[newYaku] = new Yaku (resolve, reject) ->
			addHandler self, onFulfilled, onRejected, resolve, reject

	###*
	 * The catch() method returns a Promise and deals with rejected cases only.
