move logic to template