Implementing generateTriples