migrating coffeescript to javascript