Rewrite some js to coffee