fix bug in write back