add the preference function to the code