Refactoring to make the code more readable