bug fix on extreme point detection