Z offset for each extruder

Hello everyone! My printer uses a Cartesian system with two carriages and I have 2 extruders. The problem is that when executing the SET_GCODE_OFFSET Z_ADJUST command, the offset is saved on BOTH extruders. I need the offset to be saved for each extruder when switching between them. My idea is as follows: Create an extra module that tracks the change in Z offset and remembers the extruder. When switching to the second extruder for printing, it sets the default Z offset and writes the change to a variable for that extruder. I would be grateful for any advice! I will provide a code for this extra module if it’s a the right way to solve my problem.

Please refrain from double posting. Thanks.