Fix simple algorithm