fix the bug of template selection