templates, improved query for newest data