finally got matrix working