add triangular code