Updated maxWords method with third parameter