fixed one bug, still looking for the main template is missing bug