moved the learn logic to a template