Added the preference code and comments