repalce temporary variavle with query: extract the get loop of getting total charge and getting total frequent point to a method and just leave the resdult string modification code to the statement to let the code in the same method to do something in the same lever