Infinite gas cost,

Hi all, I have an smart contract on tron blockchain, everything work as it shoulds, but when I execute a function it return the error out of energy and the transactions are reverted… It is a lottery and while more tickets are bought more energy needs to be execute the function. Thanks in advance!

The function code below:

 function Draw_Ticket() public OnlyOwner{
        require(players.length > 0,"No players have participated");
        Owner.transfer(prizePool * adminFee_percentage/100);
         marketing1.transfer((prizePool*8/1000));
        marketing2.transfer((prizePool*8/1000));
        marketing3.transfer((prizePool*8/1000));
        marketing4.transfer((prizePool*8/1000));
        marketing5.transfer((prizePool*8/1000));
        
         Topwinner_1 = players[random(players.length)];
        Topwinner_2 = players[random(players.length-1)];
        
        uint256 rewardW1= prizePool * topwinner1_percentage/100;
        uint256 rewardUpline1= prizePool*3/100;
        users[Topwinner_1].upline.transfer(rewardUpline1);
        players[random(players.length)].transfer(rewardW1);
        
        
        uint256 rewardW2= prizePool * topwinner2_percentage/100;
        uint256 rewardUpline2= prizePool*2/100;
        users[Topwinner_2].upline.transfer(rewardUpline2);
        players[random(players.length-1)].transfer(rewardW2);
        
        Id++;
        
        winners.push(Winner(Topwinner_1,prizePool * topwinner1_percentage/100,block.timestamp));
        winners.push(Winner(Topwinner_2,prizePool * topwinner2_percentage/100,block.timestamp));
        
        emit  Winner1Status(' Winner 1:', Topwinner_1, prizePool * topwinner1_percentage/100, block.timestamp);
         emit  Winner2Status(' Winner 2:', Topwinner_2, prizePool * topwinner2_percentage/100, block.timestamp);
        
        emit  Winner1referral('Referral(Winner 1):', users[Topwinner_1].upline, rewardUpline1, block.timestamp);
         emit  Winner2referral('Referral(Winner 2):', users[Topwinner_2].upline, rewardUpline2, block.timestamp);
        
        
        
        prizePool = address(this).balance;
        players = new address payable[](0);
        tickets =  2760681;
         soldtickets= 0;
    }