Refactor coffeescript