ElementFilter algorithm improvement