add data writing function for private algorithm