A small algorithm change