improved counting the number of years