rewrite back-end in coffeescript