JS rewritten in CoffeeScript