do not create function inside loop
move file pattern out, separate showImage func