fix to handle_error thanks to tim