update to matrix code