indexed times by date and refactored vars for readability