connection refactor