refactored settings code