Fix a bug in the polling code