factor out setup stuff