mapping for inserting brackets refined