Fixing reassignment of variables