Fixed variable ref error