Fixed the looping over objects arrray