   $(".categories-chooser").chosen()
 
 Template.category.helpers
-  'events': -> getEvents(categories: Session.get "category")
+  'events': -> get_events(categories: Session.get "category")
 
 Template.search.helpers
   'found_events': ->
     q = Session.get("q")
     re = new RegExp("#{q}.*", 'i')
-    getEvents($or: [{name: re}, {description: re}, {categories: re}, {location: re}])
+    get_events($or: [{name: re}, {description: re}, {categories: re}, {location: re}])

  'when': ->
    "#{moment(@from).calendar()} - #{moment(@to).calendar()}"

getEvents = (criteria, projection) ->
  if not criteria?
    criteria = {}
  if not projection?
    projection = {}
  _.extend(criteria, {to: {$gte: new Date()}})
  _.extend(projection, {sort: {from: 1}})
  Events.find(criteria, projection).fetch()

Template.all.helpers
  'all_events': -> getEvents()

# events template
Template.events.helpers

      event_ids = []
      not_flat = Meteor.users.find("profile.admin": true).map (admin) -> admin?.profile?.events or []
      event_ids = event_ids.concat.apply(event_ids, not_flat)
    get_events({_id: {$in: event_ids}})

# user template
Template.user.helpers
  'info': ->
    Meteor.users.findOne(Session.get("user_id")) or {}
  'user_events': ->
    get_events(creator: Session.get("user_id")) or []
  'following': ->
    Meteor.user()?.profile?.following.indexOf(Session.get("user_id")) > -1

