fixed some of the references in the function that were causing errors