search fixed to work together with sorting