better input parsing, ap state