automatic ID assignation and counting