refactoring the coffeescript