Help with callbacks

hello, my code gets a random Jobid of the current running servers of a chosen place with an ignorelist of jobids. I want to know if I callbacks for when it choses a Jobid that is in the ignorelist.

local GetRandomJobId = function()
	local JSONDecode = HttpService:JSONDecode(HttpService:GetAsync(string.format("https://games.roblox.com/v1/games/%s/servers/Public?sortOrder=Asc&limit=100", tostring(PlaceId))))
	local JobId = JSONDecode.data[math.random(1, table.getn(JSONDecode.data))].id
	if table.find(JobIds, JobId) then
		repeat
			JobId = JSONDecode.data[math.random(1, table.getn(JSONDecode.data))].id
		until not table.find(JobIds, JobId)
		return JobId
	else
		return JobId
	end
end

in my current code I am using a repeat until but is this the best way to do it?

  1. You’re going through job IDs randomly, which means that while checking, it may check some of them multiple times — this shouldn’t have a serious impact on performance but could be optimized. I think one of the possible ways would be to remove the ignored job IDs from the table of all job IDs and then picking a random one.
  2. The script will be in a permanent loop if all job IDs are blocked. Depending on how your list of ignored job IDs are made, this may not be possible in the first place — if it was, though, I would recommend resolving it. That should most likely be possible using the above method as well, as it would give you an empty table if all job IDs were blocked.