edited generateRandomBoard with a flag