Code to update beta using threads