Reduce some duplicated code from 0d4bfe5f522a
Reduce some duplicated code from 0d4bfe5f522a

This also makes sure that the code will work
if we change or introduce behavior somewhere
else in these functions

avdg/ppi-framework-old