update demo to add error handler