optimise contains