implemented CSCAN algorithm