refactor and address a date filter issue