cleaned up polling code