clean up and improve performance of letter_frequencies method