Now correctly inserts indices inside the brackets