Fix _.object

Move the conditional statement to the outside of the loop, and use internal `each` instead of loop.