changed mutex to atomic bool