refactor and re-organize making code easier to extend and maintain