modified countModule function