PUD: move state determination into its own function