added error and warn count. replaced all errors with error func
looking into scope issues