Hi Sultan,
I think you are in the right direction of achieving it. However, you may need to modify the callback code a bit in your case.
You will need to initialize the mask and in the callback corresponding, you need to make use of the "add_block" and "add_line" functions to add the out blocks and connect them to relevant ports. The number of blocks may be dependent on the value you set.
Thank you,
Adithya