Refactor to allow testing of multiple patterns