fix a bug in MAX_DEPTH