refactor template panel creation