total refactoring to coffeescript