updates to fix replacement bugs