Refactoring to make code easier