refactor; then handler
conform to Promises A+ 1.1
use setImmediate if available