Code added to only proceed with valid times, dates