added example
added better error reporting