Fix to work with sorting and filtering