Sorting is not correct, fix it