lib: moving result collection to external function