Changing to reflect use of AttributeDict:
Much more readable code