Performance enhancing refactor