modify error handling and session