how does a connecting flight work