support two type algorithm