refactored the connection system