rewrite client and server in coffeescript