write and erase (a bug in write)