Move boundary conditions outside of the main loop.