Rewriting JS in CoffeeScript