added thumbnail tool, restructured to avoid code doubling