DRYing up the code a little and fixing a bug with the calendar