fixed sorting stuff