adding matrix code