improved mathematica scripts