fixed sorting issues