Converted to coffeescript - still buggy
Coffeescript conversion fully functional