wrote read() and save() functions