added changeable maxdepth