debugged gendata script

Fixed bugs in gendata