added all missing code and formatting to coffeescript