Refactor for integration