modernized algorithm filtering points