my modified copy of AlexHZ's pushpool