Converted to CoffeeScript for fun