Logic change to array instead of index.