Reimplement the last part of the flooding algorithm