fixing periodic b.c.