refactor for coffeescript