added saving of preferences