This is meaty enough that it should probably be broken out into a separate method.