[4.2] Reduce cyclomatic complexity & duplicated code