Settings: unify duplicated code