refactored start and end date checking