finish switch function