changed event conditions from inequalities to zero detection plus crossing direction, to comply with SOM