This might be better extracted as a method for testing.