Modify the loop for imposing the Dirichlet Boundary condition