May I suggest a refactor of this if-else chain?