Refactoring to make DRY