better closing of connections