Changed Trials to Iterations for clarity. Added Error Checking