improved is_valid_action; fixes #32