Added a better error management