Make readPreference variable local, not global

Make `readPreference` variable local, not global, to prevent global memory leak.