Single-threaded version works