flooding algorithm works