cleaned up and added preferences