fix bug in id generation