made fog connection reusable function.