Refactoring hoping to increase performance