started rewriting using CoffeeScript