Error handling in main sequence