 	then: (onFulfilled, onRejected) ->
 		self = @
 
+		if @_state == $pending
+			@_thenIndex++
+
+		thenIndex = @_thenIndex
+
+		addHandler self, thenIndex, onFulfilled, onRejected
+
 		new Promise (resolve, reject) ->
-			addTrigger self, onFulfilled, resolve, onRejected, reject
+			chainHandlers self, thenIndex, resolve, reject
 
 	catch: (onRejected) ->
 

		See: http://jsperf.com/call-vs-arguments
	###

	# These are some static symbols.
	# The state value is designed to be 0, 1, 2. Not by chance.
	# See the genTrigger part's selector.
	$resolved = 0
	$pending = 1
	$rejected = 2

	_state: $pending
	_value: null

	# For better performance, the array is like below,
	# every four callback are paired together as a group:
	# [ onFulfilled, resolve, onRejected, reject, ... ]
	_handlers: []

	_thenCount: 0

	nextTick = do ->
		(fn) ->

		self._state = state
		self._value = value
		i = 0
		len = self._thenIndex

		while i < len
			# Trick: Reuse the value of state as the handler selector.
			k = i++ * 4 + state

			thenHandler = self._handlers[k + 2]

			if thenHandler
				chainHandler self._handlers[k](value), thenHandler
			else
				self._handlers[k] = self._handlers[k] value

		return
