proper variable scoping & first week calculation fix