Thanks @losanti for reporting
get_valid_ami_tag checks whether p-tag is strictly after the indicated one
get_valid_ami_tag