refactored unmaskingcontrolcharacter code