Refactored to extract stateparser to a different package