Refactored connection