singlethread version is implemented, but not debugged yet