connect was being called twice