converted model functions to coffeescript
defined my own flatMap instead of using _.flatten()