Refactoring to make code slightly more readable