refactor using mem pool