Modified changeActive function