refactored to make settings more efficient