some helper functions written in coffeescript