change to single thread implementation