first attempt at better handling of connections