MBS-4094: improve macro code