added factorize all and segementIntersect