refactor, add benchmarking