Refactored code.
Added conditional to date filters.