move templates code to templates dir