You are testing for mask.any() here again...? I do not see where fill_front changes in this loop (test needed each iteration)?