Add functions and failsafe loop