modified a bit the mathematica script