Added function substituteObjects