Maybe using a dictionary with the id as index would be faster?