improve code, add benchmark.