moved ParseState code into state.rs