refactor using user defaults to using managed objects