improved random npid generation