Refactoring for code clarity