move init function to tpl file