Updated code, moved away from static to allow multiple connections