added general algorithm to readme