refactored Connection class