should this get DRY'd up into a function since it's used more than once.