changed the way to calculate the id and how we were inserting entities in the arraylist