fix inplace replacement