fix boundary bug