made cyclomatic complexity go from 6 to 4