Solution for 500 points problem