translated sourcecode from javascript to coffeescript