refactor and document the calendars helper