Refactoring the factory and objects to use a repository with JSON