Add type check for $config in Factory