refactored Connection factory