fix bug in mat reader