fixing thumbnail js logic