Fix bug with assigning a matrix