Preferences added but code needs refactoring