fix for periodic BCs