Refactoring for better performance.