Changed way of looping through image