refactor the code, make the framework more testable