public function createInstance($reference, array $parameters = [], $shared = true)
    {
        $reference = $this->mapReference($reference);

        //if we have already created this reference;
        if (isset($this[$reference])) {
            return $this[$reference];
        }

        //check if $reference is already bound and return if is instance;
        $class = new ReflectionClass($reference);

        //Check that we can instantiate this class;
        if (!$class->isInstantiable()) {
            throw new \InvalidArgumentException(sprintf('Identifier "%s" is not instantiable.', $reference));
        }

        //Wrap the call function in a lamda;
        $callable = $this->wrapInCallable($class, $parameters);

        //if instance is defined and is instance wrap in closure and return;
        return ($shared)
            ? $this->createSharedReference($reference, $callable)
            : $this->createReference($reference, $callable);

    }