Improved the error management