finally working maxdepth and arrival