added checks for availability of triangle faces to avoid segfaults