better switch code