This function and its various versions seems like a lot of code just to support one assert.