fixed var assignment bug