reworked recursive diff implementation