adjust some code for viewWillAppear