     pagerDutyGet msg, "/schedules", query, (json) ->
       buffer = ''
       schedules = json.schedules
-      if schedules
+      if schedules.length > 0
         for schedule in schedules
           buffer += "* #{schedule.name} - https://#{pagerDutySubdomain}.pagerduty.com/schedules##{schedule.id}\n"
         msg.send buffer
       else
         msg.send 'No schedules found!'
-
 
   robot.respond /(pager|major)( me)? (schedule|overrides)( (.+))?$$/i, (msg) ->
     query = {

          'end':       end,
          'user_id':   userId
        }
        withCurrentOncall msg, scheduleId, (old_username) ->
          data = { 'override': override }
          pagerDutyPost msg, "/schedules/#{scheduleId}/overrides", data, (json) ->
            if json.override
              start = moment(json.override.start)
              end = moment(json.override.end)

        msg.send "Something went weird."

  # who is on call?
  robot.respond /who('s|s| is)? (on call|oncall)( for (.+))?/i, (msg) ->
    query = {}
    if msg.match[4]
      query['query'] = msg.match[4]
    pagerDutyGet msg, "/schedules", query, (json) ->
      schedules = json.schedules
      if schedules.length > 0
        for s in schedules
          withCurrentOncall msg, s, (username, schedule) ->
            msg.send "* #{username} is on call for #{schedule.name} - https://#{pagerDutySubdomain}.pagerduty.com/schedules##{schedule.id}\n"
      else
        msg.send 'No schedules found!'

  parseIncidentNumbers = (match) ->
    match.split(/[ ,]+/).map (incidentNumber) ->
