This pattern repeats, could it be made DRY?