[NGRINDER-486] Fix the dependency calc logic