sort of completed: refactoring for adding presistence