fixed error in writing