changed < lev+1 to <= lev