Fixed potential sorting issue