Remove some repeatable logic into its own class for reuse