checkConnections function added