add template loader and fix the bugs