Restore headless code logic