minor refactoring to make code more readable