you might try writing all this in coffeescript