more standard error handling.
bug on errstr