Fix problem with incorrect variable assignment