changed logic in date calculation after question on forum