Fixed 0 and 1 array indexing mismatch