add counter to control when data is saved