switched variable name form  to  in a few functions to improve clarity of intent