Struggled with coffeescript scoping and conversion