showImages: Rework code, remove duplicated code