Fix variable assignment bug