tidy up error reporting