Added depth first search method