fix boundary problem