Small refactor to use a classFactory