Fix sorting problem