implement some preference features
Code refactory