nit: Would you mind using switch-case here?