improved logic for checking htn states