Refactored observer to use factory for states