Make poll function generic