Updated popToViewController method