Fixing bug in var assignment