connect and close