modify to work with matlab
t