updated triangulation function to speed up