new algorithm for getting id