Revision to date logic to make it dynamic