need parens around these conditions: (latest_lastmod is None or lastmod > latest_lastmod)