adding error count and local flag