This function is a nice aggregation of the logic duplication elsewhere, but best I can tell it's producing identical results so there's no way it's fixing a bug. What's the fix?