conversion from javascript to coffeescript