add code for appdelegate preference