swithc func buggy