fix a bug in insert function, add word_flag to val