Revise error handling