initial edits to boundary subroutine, added switch for periodic/non-periodic on-off