Properly handle errors