Store used connection to the global variable "connection" correctly