Added null check for program in random.. Changed to be one null check for all in the generate(program) method