Fix: Implemented correct error handling