bug fixed in writting data