Having not worked with coldfusion before I was asked to look into some strange intermittent bugs in a coldfusion application.

After reading about scopes I believe the problem is because none of the variables in my cfc functions are using the `var` keyword, and the same variable name is used in various functions. So as I understand it the variables are scoped at page level and different threads calling these functions will be overwriting the variable causing the "strange" problems.

My question is what is the proper way to do this?

```
 <cfset var listCount = 0>
 <cfquery name="qGetElementsByType" dbtype="query" maxrows="#arguments.num_to_return#">
    SELECT elementId,
           title, PIhtml, Rerhtml,
           text, url, image, Rank, isPoll, pollId, subjectId
    FROM   arguments.element_query
    WHERE  <cfloop list="#arguments.element_type_id#" index="lcv">
               <cfif listCount GT 0>
                  OR
               </cfif>
               subjectid =  #lcv#
              <cfset listCount = listCount + 1>
           </cfloop>
</cfquery>

```

Does `var` need to be added each time the listCount variable is set, or just on the initial declaration?