Encapsulate pool logic to func.