Bug fix for 'mat=?' function