replacing flag variable