changed method from sort to max