fixed bug in connect