Added conn variable outside the loop