added better error reporting to example script