refactor of publicObj to factory