Some refactor and dynamizing the templates