more efficient way for checking for connections and removing obsolete connections