refactored connections algorithm again