added robustness to inflexion detector