added a writing loop3