added pbc function