added support for define number of connections as a paramater