fixed sorting problem