Feature/logic out of templates