use algorithm and range for