fixed a bug in the error management