String contains test to prevent unnecessary work