Added code for multiple tiers.