Cyclomatic complexity refactoring