next improvement for isActive function