add dirty check logic