modified error handling