Re-implemented using CoffeeScript