fixing broken triangles
adding error checking for invalid triangles