lock id generation code can possibly be moved to a helper method