private function prepareArgs(ActionModel $targetAction, $indexedArgs, $searchHashedArgs)
    {
        $preparedArgs = [];
        $paramIndex = 0;
        $params = [];

        /** @var ParamModel $param */
        foreach ($targetAction->getParamCollection() as $param) {
            $params[$paramIndex] = $param;

            $paramName = $param->getName();

            if (isset($indexedArgs[$paramIndex])) {
                $preparedArgs[$paramIndex] = $indexedArgs[$paramIndex];
            }

            foreach ($searchHashedArgs as $searchHashedArg) {
                if (is_object($searchHashedArg) && $searchHashedArg->$paramName) {
                    $paramClass = $param->getType();

                    if ($paramClass) {
                        $dryObject = new $paramClass();

                        $hydrator = new Hydrator();

                        $hydratedObj = $hydrator->hydrateObject($dryObject, $searchHashedArg->$paramName);

                        $preparedArgs[$paramIndex] = $hydratedObj;
                        continue;
                    }

                    $preparedArgs[$paramIndex] = $searchHashedArg->$paramName;
                    continue;
                }

                if (isset($searchHashedArg[$paramName])) {
                    // check for string that are really json objects
                    $obj = json_decode($searchHashedArg[$paramName]);
                    if ($obj) {
                        $paramClass = $param->getType();
                        $preparedArgs[$paramIndex] = $obj;
                        $dryObject = new $paramClass();

                        $hydrator = new Hydrator();

                        $hydratedObj = $hydrator->hydrateObject($dryObject, $obj);

                        $preparedArgs[$paramIndex] = $hydratedObj;
                        continue;
                    }

                    $preparedArgs[$paramIndex] = $searchHashedArg[$paramName];
                }
            }

            $paramIndex++;
        }

        return [$preparedArgs, $params];
    }