refactor for reuse