refactor: reduce complexity

Avoid if-else-block chaining by returning early.