added template and fuxed with controller