write data at each step