updated to support pthread