more elegant use of str.endswith