More refactoring to improve readability