refactor - put rand in generate endpoint