added error handler per discussion with @vkarpov15