Fix bug when building the objects array