Fix to return the sorted results