Refactored function into getWeekOfEvents(), and some other changes