improved max pitch detection