Refactored to create an inheritance hierarchy of algorithms