rewrite in coffeescript