solve the if loop cannot contain case if not in switch loop