Moved code to viewWillDisapper and viewDidAppear