NXP-10974: format/cleanup
NXP-10974: no need to encode parameter that will be encoded anyway a few lines below
NXP-10974: reorganize code without changing the logic