refactored #each and #eachThen implementations