remove unneeded var
refactor code to handle when run dependencies reach 0