refact mode for repeat grammar