fixed array indexing problems