Refactor loop to be more coffeescript-y