fix bug in Connect routine