add loop condition and comments on gen_loop_pattern.rb