properly open and close escape sequences