added new fields for time dates, and refactored the logic