Nesting this def inside the def of the [] method isn't great. It should be pulled out and made private.