Rewrite a main script in CoffeeScript