reverse_brackets() new internal function