function to correct noncubic pbc