added depth parameter to control the iterations