Refactored the dependency update logic