restructure and refactor