added sara's suggestion for restarting when script gets stuck in the middle