fixed bound in Count function