fix bug in generate fields