reducing cyclomatic complexity without affecting logic