Optimization & refactoring