Corrected the filter logic