refactor the code organization