fix order of variable assignment