refactor the architecture