Make readPreference variable local, not global