This is copied and pasted three times in this helper file, any way to DRY it up?