first stab and trying to factor out some commonalities