I know this is old code, but it looks hacky. It would be nice if we had a hash to perform easy lookups.