added JavaScript error handler