Fixed open/close connection issue