update error handling logic