refactoring coffeescript