fix rewrite from array for query vars
rewrite to switch ttemplate into defined one
todo comments