fixed wrong query in template