Longer reproductive lifespan linked to better cognitive function