     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 = {

      until: oneHour,
      overflow: 'true'
    }
    pagerDutyGet msg, "/schedules/#{scheduleId}/entries", query, (json) ->
      if json.entries and json.entries.length > 0
        cb(json.entries[0].user.name)

  pagerDutyIncident = (msg, incident, cb) ->
    pagerDutyGet msg, "/incidents/#{encodeURIComponent incident}", {}, (json) ->

        msg.send "#{q} matched #{json.schedules.length} schedules. Can you be more specific?"
        return

  withCurrentOncall = (msg, schedule, cb) ->
    oneHour = moment().add('hours', 1).format()
    now = moment().format()

