Refactor the switch mechanic