fixed sorting errors