Change updateFlag to be on each row and not global