move code in tpl file