refactored randomizer