remove duplications from switch functions