Handle errors properly