Added better error reporting