fix array indexing