minor fix and matrix form in boundary condition