refactor to read prefs in init