added support for an optional block to #connect