Fix multiple instance loop bug