simplify code, decrease cyclomatic complexity from 12 to 9 by
extracting methods