converted indexes from matrix to lists