fix overflow in contains