repaired overwriting variables