fixed problem with sorting