refactored connections logic A LOT