Started to implement thread version