AC Phase Control By Tweaking PWM Output to trigger Triac

Hello there,
While I was having a hard time controlling the phase shift between PWM and AC while working on the AC Triac trigger circuit with PWM control, I saw this code and saw it working with close to 100% performance.
I think it is much more performance than alternative solutions.
Thank you zhomeslice