Fixed the filter function