performance improvements to content_has function