works for higher number of points