title: Swift 3 - Close current ViewController and Open new ViewController
body: <p>I've gone through a tad amount of SO posts about this but none of them clearly state how to get this done in Swift 3.</p>
  
  <p>Simply put, I need to close the current view that is displayed and open a new view controller. Such that the only view controller open would be the 2nd VC</p>
  
  <p>This is the code I tried using, but when I try this the view controller gets closed without the rest of the code getting executed</p>
  
  <pre><code>//Close current VC
  self.dismiss(animated: true, completion: nil)
  
  //Open the new VC
  let mainStoryboard: UIStoryboard = UIStoryboard(name:"Main",bundle:Bundle.main)
  let secondViewController: SecondViewController = mainStoryboard.instantiateViewController(withIdentifier: "SecondViewController") as! SecondViewController
  self.present(secondViewController, animated: true, completion: nil)
  </code></pre>
  
  <p>Can someone help me out? I just need a simple transition from 1st VC to 2nd VC and close the 1st VC.</p>