rewritten to coffeescript ;)