Added failsafe to main