switched variable name form  to  in a few functions to improve clarity of intent.  fixed some issues with using a CSD doc vs a result set