More refactoring to avoid duplication