Refactoring to make code more readable