Using in-place operations gives nearly 10X speedup