Refactor the identification of the dirty cells