use faster max algorithm, but it's broken