Fix bug in unique ID generation