Fix filter and sort functionality