age count algorithm