check var before loop