Reordering the loops in getContacts(int... ids)