refactor to coffeescript