more refactoring on the splitTriangles method