[#11630] Removed globals and replaced with a dedicated function.