added CountSubs function