created a dictionary for each index of matrix