Fixed something up with sorting