I am not sure about the conditions Line 111 and 126. Maybe the preferences should be checked there too.