fix #227 fix infinite loop when search template