Refactoring out code duplication DRY FTW