Converted code to Coffescript