Fix variable passed by ref error