fixed var ref bug