Revert "make the code less complex"

This reverts commit e613e9ff9144f5257371d5806cf23361fb26066c.