fixed bug where maxDepth became undefined in timeout function