added dirty checking