The connect function always requires an existing object.
It is a good idea to keep the connect statements as close as possible to the object creation. Or to put it in a different way, always make sure that when you create a connection, both the sender and receiver objects exist.