sorting correctly