Refactoring few methods for better performance