[Refactor] change if clauses into swith clause.