this should really all be coffeescript