[4.2] Reduce cyclomatic complexity & duplicated code

Another great idea. I'll update it soon. Thanks!