get around the memory issue in MATLAB