Added logic with preferences.