Added the periodic case