Fixed passed by reference bug

Fixed an issue where a variable that was passed by
reference into a function was then again dereferenced