Fix computation of level when max is reached