rewrite the 500 and 1000 points algorithm