fixing Cyclomatic Complexity