working templates + db query example