Some very minor code refactoring to remove some duplication