added better filtering logic which handles date with null pretty well