added exception handdle for closed connection