modified poll function