tidy up the connection logic with a context manager