protected function wrapInCallable($class, array $parameters = [])
    {

        return function ($container) use ($class, $parameters) {

            //if reflection class has a constructor
            if (($constructor = $class->getConstructor()) !== null) { //will return null if no constructor;
                //The container will always be passed as the last argument to the constructor;
                if (($required = $constructor->getNUmberOfParameters()) > 0) { //int

                    $dependencies = $constructor->getParameters();
                    $passed = count($parameters);
                    $needfrom = ($required - $passed) > 0 ? (($passed - 1) < 0 ? 0 : $passed - 1) : $required;

                    for ($i = $needfrom; $i < $required; $i++) {
                        $parameter = $dependencies[$i]; //instance of ReflectionParamter;
                        //If this parameter has not been passed, and the default value is not defined
                        if (!$parameter->isOptional() && !$parameter->isDefaultValueAvailable()) {

                            $hintedType = $parameter->getClass();
                            $hintedTypeName = $hintedType->getName();
                            //$hintedInstance = null;

                            //$hintedType = $reflectionException = null;
                            try {
                                //if the required class exists in the container


                                //If its not in the container, we will try to load it;
                                if ($hintedType->isInstantiable()) {
                                    $hintedInstance =
                                        ($hintedType->getName() == "Budkit\\Dependency\\Container") ? $container
                                            : $container->createInstance($hintedType->getName());
                                    array_push($parameters, $hintedInstance);

                                }
                            } catch (ReflectionException $reflectionException) {

                                //print_R($hintedInstance); die;

                                throw new ReflectionException(
                                    sprintf('The %1s Class requires parameter number %2s which could not be located. %3s',
                                        $class->getName(), ($i + 1) . " of type {" . $hintedTypeName . "}", $reflectionException->getMessage())
                                );
                            }
                        }
                        //if this parameter has not been passed but we have default values
                        if ($parameter->isDefaultValueAvailable()) {
                            array_push($parameters, $parameter->getDefaultValue());
                        }
                    }
                }

                //var_dump($class, $parameters, "<br />");
                return $class->newInstanceArgs($parameters);
            }

            return $class->newInstanceWithoutConstructor();
        };
    }