Added code to discard out of bounds triangles