fixed thumbnail flickering with .replaceWith()