refactored UTF-8 validation and iteration