refactored state to own file