Take a filter + pipeline approach.

Perhaps this'll give a bit more of a solid structure to work from.