Error handling: Incorporated review comments