fix boundary conditions