fix critical shallow copy bug