move duplicated code to update_distribution
implement Settings with tests