more refactoring for readability