Fixed bug with index checking of objects