fixed bug for close connection