more perf refactoring