added pthread implementation