now works for multiple images