some matrix code needed