Reworked the way depth first works