Clean up code
Convert js to coffeescript