fix logic to resolve dependencies.