optimize reduce points algorithm
better?