my last_nth = grep{ $history{ $_ } == ($histcount - $n } keys %history;