created connect_to_server function