generate and reset commands for rand