reduce wordiness; fix boundary conditions