Added check for plateau. The code broke if it did not find a legitimate peak