Updated overall logic to suit multiple objects