Another attempt at fixing the variable bug