array indexing fix