Fix cyclomatic complexity