refactor to allow multiple connections