Helper to parse state