refactor using coffeescript