updated logic to handle null numwords entry, and logic to handle numwords > 20