Fix PMD cyclomatic complexity