Refactor for reduced complexity