refactor and re-organize making code easier to maintain