Adding triplets code