Improve logic for settings validation