Despaghettify the tag reading code.