working on sorting functionality