added periodic boundary conditions