This code has nothing to do with order by. Should it be in its own function called after this one?