fixed bug with delete and replace