public function execute()
    {
        if (!$this->CurrentActionID) {
            throw new Exception(
                sprintf(_t(
                    'WorkflowInstance.EXECUTE_EXCEPTION',
                    'Attempted to start an invalid workflow instance #%s!'
                ), $this->ID)
            );
        }

        $action     = $this->CurrentAction();
        $transition = false;

        // if the action has already finished, it means it has either multiple (or no
        // transitions at the time), so a subsequent check should be run.
        if ($action->Finished) {
            $transition = $this->checkTransitions($action);
        } else {
            $result = $action->BaseAction()->execute($this);

            // if the action was successful, then the action has finished running and
            // next transition should be run (if only one).
            // input.
            if ($result) {
                $action->MemberID = Security::getCurrentUser()->ID;
                $action->Finished = true;
                $action->write();
                $transition = $this->checkTransitions($action);
            }
        }

        // if the action finished, and there's only one available transition then
        // move onto that step - otherwise check if the workflow has finished.
        if ($transition) {
            $this->performTransition($transition);
        } else {
            // see if there are any transitions available, even if they are not valid.
            if ($action->Finished && !count($action->BaseAction()->Transitions())) {
                $this->WorkflowStatus  = 'Complete';
                $this->CurrentActionID = 0;
            } else {
                $this->WorkflowStatus = 'Paused';
            }

            $this->write();
        }
    }