thread version 4 times faster