refactored coffeescript