fix boundary problem in contains