added some ghetto sorting functionality