fixed var pass by reference bug