First version - Single threaded