replaceImage function cleanup