adding dirty flag to speed up performance
adding dirty flag to speed up performance