Transfered javascript to coffeescript