I think this needs to be broken out to its own function.