refactor coffeescript into class