Refactor to make code easier to read and use