same as the preceding example, but we store state in the layer rather than as a view controller property, which seems more encapsulated
minor formatting