Changed image selecting code.