added ability to limit depth