rewrite js with coffeescript