added a bit of error reporting