fixed problem with infinite loop while generating records