Moved the date variable to where it will be used.