Extract entity id element creation into a new function