changed back to pthread mutex