refactor code to parse templates moved to semantic