fixed the sorting