moved error situation handling back to main