fix issue with not closing connection