minor change: separate the part using trtrs to a dedicated function