fix buggy previous algorithm for checking numbers of packages to be updated