adding better error reporting