Improve error management