fixed bug in triangularMatrix function