added calculation of boundary conditions