fixed bug in error reporting code