refactoring, speedup