tidying up the js code and adding coffeescript file