added last_error
error handling