fix sorting issues