check return value for failure

minor changes