implimented a version in coffeescript