updated depth first search