changed triangular function to vectorized version