replaced sweep.pl with faster c code