polyfill implementation of contains function