can we make this more generic/DRY?