refactor for maintainability.