Resolved issue with date logic