added a randomize option to generate.bar