fix cyclomatic complexity, comments and elseif statement