added error handler for scripts