refactoring, new optimizations