Small refactor: create a subroutine updateMonthData

Instead of copying this code over and over.