Refactored generating letter frequency.