rewrote via coffeescript