Perl Flow control

Hi

I am having a very simple problem in understanding how the results between each task is being transferred. I want to run a very simple script: optimisation followed by a series of NVT runs (script below). Two questions:
1. When I run I get an error message: he trajectory document does not contain a trajectory object in Forcite.Dynamics (function/property "Run") at -e line 18. Why? I understand \$doc object should contain the trajectory after optimization. Or not?
2. If so or not where the trajectory after the task is performed is stored? 

Best

Lukasz

#!perl

use strict;
use Getopt::Long;
use MaterialsScript qw(:all);

my \$doc = \$Documents{'sc_test.xsd'};


#Geometry optimization
my \$results = Modules->Forcite->GeometryOptimization->Run(\$doc, Settings(
    Quality => "Fine", 
    CurrentForcefield => "pcff"));
#\$doc = \$results->Trajectory;
#Equlibration from 750 to 303 for 50 ps each

for (my \$i = 1;\$i<=6;++\$i) {
my \$results = Modules->Forcite->Dynamics->Run(\$doc, Settings(
    Quality => "Fine", 
    CurrentForcefield => "pcff", 
    TrajectoryRestart => "Yes", 
    AppendTrajectory => "Yes", 
    Ensemble3D => "NVT", 
    Temperature => 750-(750-303)/5*(\$i-1), 
    NumberOfSteps => 500, 
    TrajectoryFrequency => 50, 
    Thermostat => "Berendsen"));
}