Fix to handle errors correctly