modify connect for while