modified max pitch function