do not close connection in wrong place