rewrite of connect to server class