grouping activities and checking agasint closed set