Added preferences code