Fixed dispatch functie, now takes extra depth into account