improve panel switch function