slightly farther along to creating a generic algorithm