Change code to use image array