fix
reopen closed connections
refactoring